home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- // RedGreen.c
- //---------------------------------------------------------------------------
- // Contains control procedure for RedGreen control
- //---------------------------------------------------------------------------
-
- #include <windows.h>
- #include "vbapi.h"
- #include "RedGreen.h"
-
- //---------------------------------------------------------------------------
- // Local Prototypes
- //---------------------------------------------------------------------------
- BOOL _export FAR PASCAL AboutDlgProc(HWND hDlg, USHORT msg, USHORT wp, LONG lp);
-
- //---------------------------------------------------------------------------
- // Global Variables
- //---------------------------------------------------------------------------
- HANDLE hmodDLL;
- HBITMAP RG;
-
- //---------------------------------------------------------------------------
- // RedGreen Control Procedure
- //---------------------------------------------------------------------------
- LONG FAR PASCAL _export RedGreenCtlProc
- (
- HCTL hctl,
- HWND hwnd,
- USHORT msg,
- USHORT wp,
- LONG lp
- )
- {
- switch (msg)
- {
- case WM_CREATE:
- SetWindowPos(hwnd, 0, 0, 0, 29, 16, SWP_NOMOVE);
- break;
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- BOOL Value;
- HDC MemDC;
- HBRUSH hBrush;
- HBRUSH hBrushOld;
- BeginPaint(hwnd, &ps);
-
- hBrush = (HBRUSH)GetBrushOrg(ps.hdc);
- if (hBrush) hBrushOld = SelectObject(ps.hdc, hBrush);
- MemDC = CreateCompatibleDC(ps.hdc);
- SelectObject(MemDC, RG);
- VBGetControlProperty(hctl, IPROP_RedGreen_Value, &Value);
- if (Value) BitBlt(ps.hdc, 0, 0, 29, 16, MemDC, 0, 0, SRCCOPY);
- else BitBlt(ps.hdc, 0, 0, 29, 16, MemDC, 0, 16, SRCCOPY);
- SelectObject(ps.hdc, hBrushOld);
- DeleteDC(MemDC);
-
- EndPaint(hwnd, &ps);
- break;
- }
- case VBM_SETPROPERTY:
- if (wp==IPROP_RedGreen_Value) InvalidateRect(hwnd, NULL, FALSE);
- break;
- case WM_USER:
- VBDialogBoxParam(hmodDLL, "ABOUT", (FARPROC)AboutDlgProc, 0L);
- break;
- case VBM_INITPROPPOPUP:
- if (wp==3)
- {
- PostMessage(hwnd,WM_USER,0,0);
- return (lp+1)&&(0xFFFF);
- }
- break;
- }
- return VBDefControlProc(hctl, hwnd, msg, wp, lp);
- }
- // This routine handles the 'About' Dialog Box messages
- BOOL FAR PASCAL _export AboutDlgProc
- (
- HWND hDlg,
- USHORT msg,
- USHORT wp,
- LONG lp
- )
- {
- switch (msg)
- {
- case WM_CREATE:
- // Avoid warnings on unused (but required) formal parameters
- lp = lp;
- return TRUE;
- case WM_INITDIALOG:
- return FALSE;
- case WM_COMMAND:
- if ((wp==IDOK)||(wp==IDCANCEL))
- EndDialog(hDlg, TRUE);
- return TRUE;
- }
- return FALSE;
- }
- //---------------------------------------------------------------------------
- // Register custom control. This routine is called by VB when the custom
- // control DLL is loaded for use.
- //---------------------------------------------------------------------------
- BOOL FAR PASCAL _export VBINITCC
- (
- USHORT usVersion,
- BOOL fRuntime
- )
- {
- // Avoid warnings on unused (but required) formal parameters
- fRuntime = fRuntime;
- usVersion = usVersion;
- // Register control(s)
- return VBRegisterModel(hmodDLL, &modelRedGreen);
- }
-
-
- //---------------------------------------------------------------------------
- // Initialize library. This routine is called when the first client loads
- // the DLL.
- //---------------------------------------------------------------------------
- int FAR PASCAL LibMain
- (
- HANDLE hModule,
- WORD wDataSeg,
- WORD cbHeapSize,
- LPSTR lpszCmdLine
- )
- {
- // Avoid warnings on unused (but required) formal parameters
- wDataSeg = wDataSeg;
- cbHeapSize = cbHeapSize;
- lpszCmdLine = lpszCmdLine;
-
- hmodDLL = hModule;
- RG = LoadBitmap(hmodDLL, "REDGREEN");
- return 1;
- }
- //---------------------------------------------------------------------------
- // WEP
- //---------------------------------------------------------------------------
- // C7 and QCWIN provide default a WEP:
- //---------------------------------------------------------------------------
- #if (_MSC_VER < 610)
- int FAR PASCAL WEP(int fSystemExit);
- //---------------------------------------------------------------------------
- // For Windows 3.0 it is recommended that the WEP function reside in a
- // FIXED code segment and be exported as RESIDENTNAME. This is
- // accomplished using the alloc_text pragma below and the related EXPORTS
- // and SEGMENTS directives in the .DEF file.
- //
- // Read the comments section documenting the WEP function in the Windows
- // 3.1 SDK "Programmers Reference, Volume 2: Functions" before placing
- // any additional code in the WEP routine for a Windows 3.0 DLL.
- //---------------------------------------------------------------------------
- #pragma alloc_text(WEP_TEXT,WEP)
- //---------------------------------------------------------------------------
- // Performs cleanup tasks when the DLL is unloaded. WEP() is
- // called automatically by Windows when the DLL is unloaded (no
- // remaining tasks still have the DLL loaded). It is strongly
- // recommended that a DLL have a WEP() function, even if it does
- // nothing but returns success (1), as in this example.
- //---------------------------------------------------------------------------
- int FAR PASCAL WEP
- (
- int fSystemExit
- )
- {
- DeleteObject(RG);
- // Avoid warnings on unused (but required) formal parameters
- fSystemExit = fSystemExit;
- return 1;
- }
- #endif // C6
- //---------------------------------------------------------------------------
-